package com.ai.wxy.spring.jpa.test.controller;

import com.ai.wxy.spring.auth.dto.UserDTO;
import com.ai.wxy.spring.jpa.test.service.SpringCacheService;
import com.ai.wxy.spring.jpa.test.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试缓存
 *
 * @author 石头
 * @Date 2019/11/8
 * @Version 1.0
 **/
@RestController
public class CacheTestController {
    @Autowired
    private SpringCacheService springCacheService;

    @GetMapping("/cache/m1")
    public String method1(){
        return springCacheService.method1();
    }

    @GetMapping("/cache/m2/{userName}")
    public UserVo findByName(@PathVariable String userName){
        UserDTO query = new UserDTO();
        query.setUsername(userName);
        return springCacheService.findByName(query);
    }
}
